=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 03-13-93 (22:24) Number: 84 From: QUINN TYLER JACKSON Refer#: NONE To: ALL Recvd: NO Subj: formula solver 2/7 Conf: (35) Quick Basi --------------------------------------------------------------------------- '>>> Start of page 2. ' This function can expand factorials: ' ' 3! = 6 ' 0! = 1 ' ' 3. logical greater than, less than, and equality ' ' 5 > 4 = -1 [TRUE] ' 9 < 1 = 0 [FALSE] ' ' 4. nested parenthesis precedence override ' ' 5*(2+3) = 25 rather than 13 ' ' 5. PASCAL style variable assignment (using the ":=" of PASCAL) ' ' variable := 5+3 (assigns the value of 8 to variable) ' ' Note also that variables that have been assigned can be used ' within expressions: ' ' newvariable := 3+variable (assigns 11 to new variable based ' upon ' variable having an assignment of 8) ' So far, variables cannot be reassigned by the same expression they ' occur in. So, the following yeilds a faulty answer: ' ' x := x + 1 ' ' 6. and more! ' ' I leave it to you to figure out what 6?9 solves to! ' This FUNCTION can solve complex equations that mix all parts of the ' above! Try it out! Break it to pieces! Smoke it! It's yours! ' CONST ASSIGNMENT = ":=" ' This can be changed to suit your needs ' Using a simple = is possible, since ' logical ' equality is a double == with this parser, ' but the PASCAL standard := is easier to ' deal ' with as an assignment operator for some. ' Operator classes PRECEDENCE '--------------------------------------------------- CONST POWER = "^]?**>><<" ' FIRST CONST MULTDIV = "*/\%" ' SECOND CONST ADDSUB = "+-" ' THIRD CONST LOGICAL = "<>=&|~>==><==<<>"' FOURTH CONST OperatorClass = 1 CONST DigitClass = 2 CONST VARMAX = 100 TYPE VariableType Nom AS STRING * 30 ' variable name Valu AS LONG ' variable's value END TYPE ' Variables global to this module... DIM SHARED VarMem(VARMAX) AS VariableType DIM SHARED VariPtr AS INTEGER DIM SHARED OPERATOR$ DIM SHARED expression$ DIM SHARED TOKEN$ DIM SHARED TypeToken DIM SHARED Ptr AS INTEGER '>>> Continued on page 3. --- Maximus/2 2.01wb * Origin: The Nibble's Roost, Richmond BC Canada 604-244-8009 (1:153/918) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 950 203/23 209/209 280/1 SEEN-BY: 390/1 396/1 15 397/2 2230/100 3603/20